package com.sgb.kjwl.view.ui.adapter.lease;

import android.content.Context;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.model.entity.CarBrandEntity;
import com.sgb.kjwl.model.entity.supplier3.DictEntity3;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter2;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

/**
 * 车辆发布品牌选择适配器
 */
public class LeaseSearchAdapter extends BaseRecycleAdapter2<DictEntity3> {

    private TextView tvName;
    private String text = "";

    public LeaseSearchAdapter(Context context, List<DictEntity3> datas) {
        super(context, R.layout.item_lease_search_tip, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, final DictEntity3 entity, int position) {
        holder.setBinding(BR.viewModel, entity);
        tvName = holder.getItem().findViewById(R.id.name);
        if (text != null) {
            String temp = entity.getName().replace(text, "<font color='#5792FD'>" + text + "</font>");
            tvName.setText(Html.fromHtml(temp));
        }

    }

    public void setSelectedText(String text) {
        this.text = text;
    }

}